package cn.kicsy.www.anonymous_bbs.scheduler;

import cn.kicsy.www.anonymous_bbs.service.CcAttackDetectionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务调度器
 * 用于执行定时清理任务
 */
@Component
public class CleanupScheduler {
    
    private static final Logger logger = LoggerFactory.getLogger(CleanupScheduler.class);
    
    @Autowired
    private CcAttackDetectionService ccAttackDetectionService;
    
    /**
     * 每5分钟清理一次过期的请求计数器
     */
    @Scheduled(fixedRate = 5 * 60 * 1000)  // 5分钟执行一次
    public void cleanupExpiredCounters() {
        logger.debug("开始清理过期的请求计数器");
        ccAttackDetectionService.cleanupExpiredCounters();
        logger.debug("完成清理过期的请求计数器");
    }
}